import type { CascaderModel } from '.'

export interface CdnCascaderProps {
  debug?: boolean
  data?: CascaderModel
  isFullscreen?: boolean
  nodeEmptyTips?: CascaderNodeEmptyTips
}

export type Data<T = any> = Record<string, T>

export type NodeLevel = 1 | 2
export type LevelSiderBarType = 'error' | 'warning' | undefined
export interface CascaderStore {
  nodeMap: Record<string, Data>
}

export interface CascaderNodeEmptyTips {
  level_1: string
  level_2: string
}

export interface CascaderDiffSource extends Data {
  region: string
  level: NodeLevel
  index: number
}

/**
 * ```
 * 层级: LEVEL
 * 区域: REGION
 * 区域与层级: REGION_LEVEL
 * 排序: SORT
 * ```
 */
export type CascaderDiffType = 'LEVEL' | 'REGION' | 'REGION_LEVEL' | 'SORT'

export interface CascaderDiffData extends Data {
  node: string
  to: CascaderDiffSource
}

export interface CascaderDiff extends CascaderDiffData {
  diffType: CascaderDiffType
  source: CascaderDiffSource
}

export type CascaderUpdateModel = CascaderUpdateRegionModel[]

export interface CascaderUpdateRegionModel {
  region_id: string
  region_name: string
  node_L1: CascaderUpdateNodeModel[]
  node_L2: CascaderUpdateNodeModel[]
}

export interface CascaderUpdateNodeModel {
  node_id: string
  node_name: string
  resolv_status: number
  run_status: number
  level: number
  cache_switch: number
  cascade_level: number
  created_at: string
  updated_at: string
  region_id: string
  region_name: string
  node_ip: string
}
